<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>行政管理--用章管理</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="stylesheet" href="css/chenwenjing/chenwj.css" type="text/css"></link>
	 <link rel="stylesheet" href="easyui/themes/icon.css" type="text/css"></link>
	 <link rel="stylesheet" href="easyui/themes/default/easyui.css" type="text/css"></link>
	 <script type="text/javascript" src="easyui/jquery-1.8.3.js"></script>
	 <script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>
     <script type="text/javascript">
     
		var dname;
     	$(function(){
     		$.post("dept/findById.do","id="+$("#deptId").val(),function(data){
					dname= data.deptname;
					init();
	  			},"json");
	  			
     		$.get("word/findByName.do?name=用章类型",function(data){		
 				var id =data.id;
 				$.get("wordchild/findByWordid.do?id="+id,function(data){    					
 					if(data.length>0){    						
						for(var i=0;i<data.length;i++){								
							$("#stamper").append("<option value="+data[i].id+">"+data[i].name+"</option>");		
						}
					}
				},"json"); 
			},"json");
     		
     		$.post("dept/findById.do","id="+$("#deptId").val(),function(data){
	  				$("#deptmanagerid").val(data.deptmanagerid);	  	  				  	  			
  				$.post("users/findById.do","id="+$("#deptmanagerid").val(),function(data){
  	  				$("#deptmanagername").val(data.name);	  	  				
  	  			},"json");
				},"json");
     		
     	}); 
     		
     		function init(){
     			$("#dg").datagrid({	  		
          			url:"seal/findByCreateid.do?createid="+$("#applyid").val(),
          			striped:true,	  			
          			rownumbers:true,
          			columns:[[{
          				title:"申请人",
          				field:"applyperson",
          				width:100,
          				align:"center"
          			},{
          				title:"印章名",
          				field:"sealname",
          				width:100,
          				align:"center"
          			},{
          				title:"申请部门",
          				field:"deptid",
          				width:100,
          				align:"center",
          				formatter:function (value){
          					return dname;
          					 
    	  				}
          			},{
          				title:"申请原因",
          				field:"applyreason",
          				width:165,
          				align:"center"
          			},{
          				title:"申请时间",
          				field:"ordertime",
          				width:100,
          				align:"right",
          				formatter:date
          			},{
          				title:"状态",
          				field:"status",
          				width:100,
          				align:"center",
          				formatter:function (value){
        					if(value==1){
        						return "待审核";
        					}else if(value==2){
        						return "审核中";
        					}else if(value==3){
        						return "待审核";
        					}else if(value==4){
        						return "审核通过";
        					}else if(value==4){
        						return "已拒绝";
        					}else if(value==5){
        						return "已打回";
        					}
        				}
          			},{
    	  				title:"操作",
    	  				field:"id",
    	  				width:100,
    	  				align:"center",
    	  				formatter:function (value,row,index){
    						return "<a onclick='del("+row.id+")' href='javascript:void(0)'>删除</a>";
    					}	  				
    	  			}]]
          		});  
         		$("#myform").submit(function(){
         			if(checkstamper()==false ){
        				return false;		
        			}
         		});
     		}
     		
     		
 		  
     	function del(value){
			$.messager.confirm("提示框", "你确定要删除吗?",function(r){
				if(r){
					var data = "id="+value;
					$.post(
		  				"seal/delete.do",
		  				data,
		  				function(data){
		  				alert(data);
		  				$("#dg").datagrid("reload");
		  				},
		  				"text"
		  			);
				}
			});
		};
     	function date(value){
    		return value.year+1900+"-"
    		+(value.month+1)+"-"+value.date;
    	};
    	function checkstamper(){
 			if($("#stamper").val()==""){
				alert("请选择用章类型！");
				return false;
 			}
 		};
     </script>
     <c:if test="${message!=null }">
	<script>
		alert('${message}');
	</script>
 </c:if>
  </head>
  
  <body>
    <div id="mainbody">
    	<p><img src="css/chenwenjing/img/icons/contacts.png" width="32px" height="32px"/>&nbsp;&nbsp;<span>行政管理</span></p>
	    <div class="title">
	        用章申请
	    </div>
	    <table id="dg"></table>
	    <div class="content">
   		<form method="post" action="seal/add.do" id="myform" >
	    	<table cellpadding="0" cellspacing="0">
	    		<tr>
	    			<td>姓名：</td>
	    			<td>
						<input class="input-text" type="text" id="applyperson" name="applyperson" value="" />
	    			</td>	
	    		</tr>
	    		<tr>
	    			<td>印章名：</td>
	    			<td>
						<input class="input-text" type="text" id="sealname" name="sealname" value="" />
	    			</td>	
	    		</tr>
	    		<tr>
	    			<td>部门：</td>
	    			<td>
						<input class="input-text" type="text" id="deptname" name=deptname value="${user.deptname}" readonly="readonly"/>
						<input class="input-text" type="hidden" id="deptid" name=deptid value="${user.deptid}" />
	    			</td>	
	    		</tr>
	    		<tr>
	    			<td>用章类型：</td>
	    			<td>
						<select name="stamper" id="stamper">
								<option value="" id="st">用章类型</option>
													
						</select>
	    			</td>	
	    		</tr>
	    		<tr>
	    			<td>申请原因：</td>
	    			<td>
	    				<textarea rows="3" cols="50" class="input-text" id="applyreason" name="applyreason"></textarea>
	    			</td>	
	    		</tr>
	    		<tr>
	    			<td>申请人：</td>
	    			<td><input class="input-text" type="text" id="applyname" name="applyname" value="${user.name}" readonly="readonly">
	    			<input class="input-text" type="hidden" id="applyid" name="applyid" value="${user.id}"></input>
						
	    			</td>	
	    		</tr>
	    		<tr>
	    			<td>下一步审批人：</td>
	    			<td><input class="input-text" type="hidden" id="deptId" name="deptId" value="${user.deptid}" />
						<input class="input-text" type="hidden" id="deptmanagerid" name="deptmanagerid" value=""/>
						<input class="input-text" type="text" id="deptmanagername" name="deptmanagername" value="" readonly="readonly"/>
	    			</td>	
	    		</tr>
    		</table>
    		<input class="button" type="submit" id="submit" name="submit" value="确定" />
    		<input class="button" type="reset" id="reset" name="reset" value="取消" />
    	</form>
    	</div>
    </div>
  </body>
</html>
